{% extends "agmstaff/index.html" %}
{% block title %}工厂及宿舍报修区{% endblock %}
{% block title0 %}工厂及宿舍报修区{% endblock %}
{% set places = ['宿舍', '工厂']%}
{% set floors = ['一楼', '二楼', '三楼', '四楼']%}
{% set states = ['未处理', '处理中', '处理完成']%}
{% block otherstyle %}
table {
  margin: 1rem 0;
  max-width: 100%;
  width: 100%; }
  table th,
  table td {
    padding: 0.5rem;
    text-align: left;
    vertical-align: top; }
    [dir="rtl"] table th, [dir="rtl"]
    table td {
      text-align: right; }
    .table-striped tbody > tr:nth-child(odd) > td,
    .table-striped tbody > tr:nth-child(odd) > th {
      background-color: #ebebeb; }
   th{
      background-color:black;
      color:white;
   }   
{% endblock %}
{% block page_bd %}
<div style="text-align:right">
    <a href="." class="weui-btn weui-btn_mini weui-btn_default">返回</a>
    <a href="repair_submit" class="weui-btn weui-btn_mini weui-btn_primary">新增</a>
</div>
<div style="overflow-x:auto;white-space:nowrap;">
    <table class="table-striped">
        <thead>
            <tr>
                <th>报修地点</th>
                <th>报修楼层</th>
                <th>报修内容</th>
                <th>简单描述</th>
                <th>状态</th>
                <th>处理人</th>
                <th>报修时间</th>
                {% if isfixer %}
                <th>处理设置</th>
                {% endif %}
            </tr>
        </thead>
        <tbody>
            {% for repair in repairs %}
            <tr>
                <td>{{ places[int(repair.get('place'))-1]}}</td>
                <td>{{ floors[int(repair.get('floor'))-1]}}</td>
                <td>{{ repair.get('content')}}</td>
                <td>{{ repair.get('des')}}</td>
                <td>{{ states[repair.get('state')] }}</td>
                <td>{{ repair.get('repairName') or '暂无' }}</td>
                <td>{{ printDateTime(repair.created_at, '%Y%m%d %H:%M') }}</td>
                {% if isfixer %}
                <td>{% if repair.get('state') < 2 %}<a href="javascript:setState({{ repair.get('state') }},'{{ repair.id }}');" class="weui-btn weui-btn_mini weui-btn_primary">{{ states[repair.get('state')+1 ]}}</a>{% else %}<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary weui-btn_disabled">无操作</a>{% endif %}</td>
                {% endif %}
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}
{% block otherscript %}
setState = function(s, i){
$.post("?state="+s+"&rid="+i, function(data){
    console.info(data);
    if(data=='success'){
        location.reload();
    }
})
}
{% endblock %}
